package config

import (
	"github.com/hwcer/yyds"
	"server/share/protoc"
)

const EggPoolCacheName = "EggPoolCache"

func init() {
	yyds.Config.Register(&egg{})
}

func GetEggPoolConfig(pool int32) []*protoc.CatcherPool {
	c := yyds.Config.Process.Get(EggPoolCacheName).(map[int32][]*protoc.CatcherPool)
	return c[pool]
}

type egg struct {
}

func (this *egg) Handle(c *yyds.CS, i any) {
	data := i.(*output)
	cache := map[int32][]*protoc.CatcherPool{}
	for _, pool := range data.CatcherPool {
		cache[pool.PoolId] = append(cache[pool.PoolId], pool)
	}
	c.Process.Set(EggPoolCacheName, cache)
	return
}

func (this *egg) Verify(c *yyds.CS, i any) (errs []error) {
	return
}
